﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-10>
//创建作者：<郭登杰>
//功能说明：来函公共控件-申请理由
//********************************************************************************//
using BLL.Access;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Controls.LAIHAN
{
    public partial class UCLHShenQingLY : System.Web.UI.UserControl, IUCLHOperate
    {
        #region 属性

        /// <summary>
        /// 申请理由
        /// </summary>
        public string LiYou {
            get {
                return this.txtLiYou.Text;
            }
            set
            {
                this.txtLiYou.Text = value;
            }
        }

        /// <summary>
        /// 备注
        /// </summary>
        public string BeiZhu
        {
            get
            {
                return this.txtBeiZhu.Text;
            }
            set
            {
                this.txtBeiZhu.Text = value;
            }
        }

        /// <summary>
        /// 当前显示模式
        /// </summary>
        public eMode Mode { get; set; }

        #endregion

        #region 事件

        /// <summary>
        /// 页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();                
            }
        }     

        #endregion

        #region 方法

        /// <summary>
        /// 配置控件
        /// </summary>
        public void InitControl()
        {
            if (this.Mode == eMode.Flow)
            {
                this.fsBeiZhu.Visible = true;
                this.fsLiYou.Visible = true;
                this.fsWenJian.Visible = true;
                this.txtBeiZhu.Enabled = true;
                this.txtLiYou.Enabled = true;
            }
            else if(this.Mode==eMode.Detail){
                this.fsBeiZhu.Visible = false;
                this.fsLiYou.Visible = true;
                this.fsWenJian.Visible = false;
                this.txtBeiZhu.Enabled = false;
                this.txtLiYou.Enabled = false;
            }
            else if(this.Mode==eMode.Add){
                this.fsBeiZhu.Visible = false;
                this.txtBeiZhu.Enabled = false;
                this.fsLiYou.Visible = true;
                this.txtLiYou.Enabled = true;
                this.fsWenJian.Visible = false;
            }
        }

        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="laihanbh">来涵号</param>
        public void LoadData(string laihanbh)
        {

        }

        /// <summary>
        /// 提交验证
        /// </summary>
        ValidateRS IUCLHOperate.Validate()
        {
            ValidateRS rs = new ValidateRS();
            if (this.txtLiYou.Text == "")
            {
                rs.Msg = "来函内容不能为空。";
                return rs;
            }
            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        /// 清空数据
        /// </summary>
        public void ClearInfo()
        {
            this.txtBeiZhu.Text = "";
            this.txtLiYou.Text = "";
        }

        /// <summary>
        /// 根据来函加载信息
        /// </summary>
        /// <param name="laihanxx">来函信息</param>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            this.txtLiYou.Text = laihanxx.S_SHENQINGLY;
            this.txtBeiZhu.Text = laihanxx.S_BEIZHU;
            if(laihanxx.ID!=0)
            {
                this.txtLiYou.ClientEnabled = false;
                this.txtBeiZhu.ClientEnabled = false;
            }
            HidWenJian.Set("yonghuh",laihanxx.S_YONGHUBH);
            HidWenJian.Set("laihanbh",laihanxx.S_LAIHANBH);
        }

        #endregion        
    }
}